package com.learn.redis.concurrence.redpacket;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import utils.json.DoubleUtil;

/**
 * @author : Yu.Tan
 * @date : 2022/10/12 17:48
 * @desc : **
 */
@RestController
@RequestMapping("/redPacket")
@Slf4j
public class RedPacketController {

    @Autowired
    private RedPacketService redPacketService;

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;


    /**
     * 抢红包一
     * @param redPacketId 红包Id
     * @param userId 用户Id
     *  判断红包剩余个数
     *  抢红包 拆红包 抢到基本能拆到
     *
     */
    @RequestMapping(value = "/grab/red/one", method = RequestMethod.GET)
    public void grabRedOne(String redPacketId,String userId) {
            Integer money = redPacketService.grabRedOne(redPacketId, userId);
    }

    /**
     * 抢红包一
     * @param redPacketId 红包Id
     * @param userId 用户Id
     *  判断红包剩余金额
     *  抢红包 拆红包 抢到不一定能能拆到
     *
     */
    @RequestMapping(value = "/grab/red/two", method = RequestMethod.GET)
    public void grabRedTwo(String redPacketId,String userId) {
        Integer money = redPacketService.grabRedTwo(redPacketId, userId);
    }
}

